//
//  CheckDetailCell.m
//  MyProject
//
//  Created by Pei on 16/6/29.
//  Copyright © 2016年 Xiaobo Pei. All rights reserved.
//

#import "CheckDetailCell.h"

@implementation CheckDetailCell
{
    UILabel *_titleLbl;
    UILabel *_detailLbl;
    
    UILabel *_kouFenLbl;
    
    UILabel *_yinHuanLbl;
    UILabel *_contentLbl;
}

@synthesize titleControl;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor = kWhiteColor;
        
        UIView *topView = [[UIView alloc] init];
        topView.frame = CGRectMake(0.0f, 0.0f, kDeviceWidth, 10.0f);
        topView.backgroundColor = kDefaultBackgroundColor;
        [self addSubview:topView];
        
        UIView *lineView0 = [[UIView alloc] init];
        lineView0.frame = CGRectMake(0.0f, 10-0.5, kDeviceWidth, 0.5);
        lineView0.backgroundColor = kGreenColor;
        [self addSubview:lineView0];
        
        titleControl = [[UIControl alloc] init];
        titleControl.frame = CGRectMake(0.0f, topView.bottom, kDeviceWidth, 40.0f);
        //[self addSubview:titleControl];
        
        UIImageView *arrowImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"02jiantou-"]];
        arrowImageView.frame = CGRectMake(kDeviceWidth-10.0f/2.0f-10.0f, topView.bottom+(40-19.0f/2.0f)/2.0f, 10.0f/2.0f, 19.0f/2.0f);
        [self addSubview:arrowImageView];
        
        _titleLbl = [[UILabel alloc] init];
        _titleLbl.frame = CGRectMake(10.0f, topView.bottom+(40-(Home_Small_Size+2.0f))/2.0f, kDeviceWidth-10.0f*2.0f-arrowImageView.width-5.0f, Home_Small_Size+2.0f);
        _titleLbl.text = @"检查内容：";
        _titleLbl.font = kAppFont(Home_Small_Size+2.0f);
        _titleLbl.textColor = kBlackColor;
        [self addSubview:_titleLbl];
        
        UIView *lineView01 = [[UIView alloc] init];
        lineView01.frame = CGRectMake(0.0f, topView.bottom+40-0.5, kDeviceWidth, 0.5);
        lineView01.backgroundColor = kGreenColor;
        [self addSubview:lineView01];
        
        
        _detailLbl = [[UILabel alloc] init];
        _detailLbl.frame = CGRectMake(10.0f, titleControl.bottom+(40-(Home_Small_Size+2.0f))/2.0f, kDeviceWidth-10.0f*2.0f, Home_Small_Size+2);
        _detailLbl.text = @"检查描述：";
        _detailLbl.font = kAppFont(Home_Small_Size+2.0f);
        _detailLbl.textColor = kBlackColor;
        [self addSubview:_detailLbl];
        
        UIView *lineView = [[UIView alloc] init];
        lineView.frame = CGRectMake(0.0f, topView.height+40*2-0.5, kDeviceWidth, 0.5);
        lineView.backgroundColor = kGreenColor;
        [self addSubview:lineView];
        
        _kouFenLbl = [[UILabel alloc] init];
        _kouFenLbl.frame = CGRectMake(10.0f, lineView.bottom+(40-(Home_Small_Size+2.0f))/2.0f, kDeviceWidth-10.0f*2.0f, Home_Small_Size+2.0f);
        _kouFenLbl.text = @"扣分：";
        _kouFenLbl.font = kAppFont(Home_Small_Size+2.0f);
        _kouFenLbl.textColor = kBlackColor;
        [self addSubview:_kouFenLbl];
        //kRGB(25, 151, 198)
        
        UIView *lineVie1 = [[UIView alloc] init];
        lineVie1.frame = CGRectMake(0.0f, topView.height+40*3-0.5, kDeviceWidth, 0.5);
        lineVie1.backgroundColor = kGreenColor;
        [self addSubview:lineVie1];
        
        _yinHuanLbl = [[UILabel alloc] init];
        _yinHuanLbl.frame = CGRectMake(10.0f, lineVie1.bottom+(40-(Home_Small_Size+2.0f))/2.0f, kDeviceWidth-10.0f*2.0f, Home_Small_Size+2.0f);
        _yinHuanLbl.text = @"隐患类型：";
        _yinHuanLbl.font = kAppFont(Home_Small_Size+2.0f);
        _yinHuanLbl.textColor = kBlackColor;
        [self addSubview:_yinHuanLbl];
        
        
        UIView *lineVie2 = [[UIView alloc] init];
        lineVie2.frame = CGRectMake(0.0f, topView.height+40*4-0.5, kDeviceWidth, 0.5);
        lineVie2.backgroundColor = kGreenColor;
        [self addSubview:lineVie2];
        
        
//        UIImageView *arrowImageView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"02jiantou-"]];
//        arrowImageView1.frame = CGRectMake(kDeviceWidth-10.0f/2.0f-10.0f, lineVie2.bottom+(40-19.0f/2.0f)/2.0f, 10.0f/2.0f, 19.0f/2.0f);
//        [self addSubview:arrowImageView1];
//        
//        _contentLbl = [[UILabel alloc] init];
//        _contentLbl.frame = CGRectMake(10.0f, lineVie2.bottom+(40-(Home_Small_Size+2.0f))/2.0f, kDeviceWidth-10.0f*2.0f-arrowImageView1.width-5.0f, Home_Small_Size+2.0f);
//        _contentLbl.text = @"检查内容：";
//        _contentLbl.font = kAppFont(Home_Small_Size+2.0f);
//        _contentLbl.textColor = kBlackColor;
//        [self addSubview:_contentLbl];
//        
//
//
//        
//        
//        UIView *lineVie3 = [[UIView alloc] init];
//        lineVie3.frame = CGRectMake(0.0f, topView.height+40*5-0.5, kDeviceWidth, 0.5);
//        lineVie3.backgroundColor = kGreenColor;
//        [self addSubview:lineVie3];

        
        //UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(10.0f, (10*2+6*2+(Home_Small_Size+2)*3.0f)-0.5f, kDeviceWidth-10*2, 0.5f)];
        //lineView.backgroundColor = kGreenColor;
        //[self addSubview:lineView];
    }
    
    return self;
}


- (void)showWithData:(NSDictionary*)dataDic
{
   /*
    [dic setValue:@"无" forKey:@"JianChaMiaoShu"];
    [dic setValue:@"0" forKey:@"KouFen"];

    */
    
    NSString *titleStr = [NSString stringWithFormat:@"检查内容：%@", [dataDic valueForKey:@"InspectContentName"]];
    NSString *contenStr = [dataDic valueForKey:@"InspectContentName"];
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:titleStr];
    [str addAttribute:NSForegroundColorAttributeName value:kGreenColor range:NSMakeRange(5,contenStr.length)];
    
    _titleLbl.attributedText = str;
    
    NSString *JianChaMiaoShuStr = [dataDic valueForKey:@"JianChaMiaoShu"];
    if (JianChaMiaoShuStr == nil || JianChaMiaoShuStr.length <= 0) {
        NSString *detailStr = [NSString stringWithFormat:@"检查描述：%@", @""];
        NSString *contenStr2 = @"";
        NSMutableAttributedString *detailMStr = [[NSMutableAttributedString alloc] initWithString:detailStr];
        [detailMStr addAttribute:NSForegroundColorAttributeName value:kGreenColor range:NSMakeRange(5,contenStr2.length)];
        
        _detailLbl.attributedText = detailMStr;
    }else{
        NSString *detailStr = [NSString stringWithFormat:@"检查描述：%@", [dataDic valueForKey:@"JianChaMiaoShu"]];
        NSString *contenStr2 = [dataDic valueForKey:@"JianChaMiaoShu"];
        NSMutableAttributedString *detailMStr = [[NSMutableAttributedString alloc] initWithString:detailStr];
        [detailMStr addAttribute:NSForegroundColorAttributeName value:kGreenColor range:NSMakeRange(5,contenStr2.length)];
        
        _detailLbl.attributedText = detailMStr;
 
    }
    
    
    
    
    NSString *kouFenStr = [NSString stringWithFormat:@"扣分：%d", [[dataDic valueForKey:@"KouFen"] intValue]];
    NSString *kouStr2 = [NSString stringWithFormat:@"%d", [[dataDic valueForKey:@"KouFen"] intValue]];
    NSMutableAttributedString *kouMStr = [[NSMutableAttributedString alloc] initWithString:kouFenStr];
    [kouMStr addAttribute:NSForegroundColorAttributeName value:kRGB(25, 151, 198) range:NSMakeRange(3,kouStr2.length)];
    _kouFenLbl.attributedText = kouMStr;
    
    
    NSString *yinHStr = [NSString stringWithFormat:@"隐患类型：%@", [dataDic valueForKey:@"RiskTypeName"]];
    NSString *yinHStr2 = [dataDic valueForKey:@"RiskTypeName"];
    NSMutableAttributedString *yinMStr = [[NSMutableAttributedString alloc] initWithString:yinHStr];
    [yinMStr addAttribute:NSForegroundColorAttributeName value:kRGB(25, 151, 198) range:NSMakeRange(5,yinHStr2.length)];
    _yinHuanLbl.attributedText = yinMStr;
    
    //_detailLbl.text = [NSString stringWithFormat:@"检查描述：%@", [dataDic valueForKey:@"JianChaMiaoShu"]];
    //_statusLbl.text = [NSString stringWithFormat:@"扣分：%d", [[dataDic valueForKey:@"KouFen"] intValue]];
}

@end
